<?php
	global $_W,$_GPC;
	if($_W['role']){
		$page = $_GPC['page'];
		$pindex = max(1, intval($page));	
		$psize = 10;
		$sql = "SELECT * FROM".tablename('mii_ang_card')." WHERE uniacid=:uniacid AND roof=:roof   ORDER BY addtime DESC LIMIT ".($pindex-1)*$psize.','.$psize;
		$card = pdo_fetchall($sql,array(':uniacid'=>$_W['uniacid'],':roof'=>'mii'));
		$countSql = "SELECT COUNT(*)FROM " . tablename('mii_ang_card')." WHERE uniacid ={$_W['uniacid']} AND roof = 'mii' ";
		$total = pdo_fetchcolumn($countSql);
		$pager = pagination($total, $pindex, $psize,$url='',$context = array('before' =>1, 'after' => 1, 'ajaxcallback' => '', 'callbackfuncname' => ''));	
		include $this->template('web/card/mii_cardlist');
	}else{
		message('没有操作权限');
	}
	function cardname($type){
		if ($type == 'DISCOUNT') {
			$name = '折扣券';
		} elseif ($type == 'CASH') {
			$name = '代金券';
		} elseif ($type == 'GENERAL_COUPON') {
			$name = '优惠券';
		} elseif ($type == 'GIFT') {
			$name = '礼品券';
		} elseif ($type == 'GROUPON') {
			$name = '团购券';
		}elseif($type=='MEMBER_CARD'){
			$name = '会员卡';
		}	
		return $name;
	}	
	function date_info($json){
		$arr = json_decode($json,true);
		if($arr['fixed_term']){
			return $arr['fixed_term']."天";
		}else{
			return '不限';
		}
		
	}




?>